/*
 * Created on Sep 17, 2008
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package ro.qi.framework.sys.util.string;

/**
 * @author George Pogorelschi
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class RandomString {

	private int stringLength			= 16;
	private StringBuffer randomString 	= new StringBuffer();

	public RandomString() {
		setRandomString();
	}

	public RandomString(int stringLength) {
		setStringLength(stringLength);
		setRandomString();
	}
	
	/**
	 * @param buffer
	 */
	public void setRandomString() {
		for (int j = 0; j < getStringLength(); j++) {
			int n = (int)(Math.random()*(('z' - 'a')+1));
			char c = 0;
//			if (n < 10) {
//				c = (char)('0' + (char)n);
//			}
			c = (char)('a' + (char)(n));
			randomString.append(c);
		}
	}

	/**
	 * @return
	 */
	public String getRandomString() {
		return randomString.toString();
	}

	/**
	 * @return
	 */
	public int getStringLength() {
		return stringLength;
	}

	/**
	 * @param i
	 */
	public void setStringLength(int i) {
		stringLength = i;
	}

}
